package com.ffsky.litepack;

import com.ffsky.litepack.app.AppInterface;
import com.ffsky.litepack.cache.Cache;
import com.ffsky.litepack.cache.RawCache;
import com.ffsky.litepack.task.Tasks;
import com.ffsky.litepack.task.TasksImpl;
import ohos.aafwk.ability.AbilityPackage;

public class Lite {

    public static Cache cache;
    public static Tasks tasks;
    public static AbilityPackage abilityPackage;
    public static AppInterface appInterface;
    public static void install(Builder builder) {
            Lite.cache = builder.cache;
            Lite.tasks = builder.tasks;
            Lite.abilityPackage = builder.abilityPackage;
            Lite.appInterface = builder.appInterface;
    }

    public final static class Builder {
        public final  static Builder create(){
            return new Builder();
        }
        private Cache cache;
        private Tasks tasks;
        private AbilityPackage abilityPackage;
        private AppInterface appInterface;
        public Builder() {
            super();
            cache = new RawCache();
            tasks = new TasksImpl();
        }
        public Builder setAppInterface(AppInterface  appInterface){
            this.appInterface = appInterface;
            return this;
        }
        public Builder setAbilityPackage(AbilityPackage abilityPackage){
            this.abilityPackage = abilityPackage;
            return this;
        }
        public Builder setCache(Cache cache) {
            this.cache = cache;
            return this;
        }

        public Builder setTasks(Tasks tasks) {
            this.tasks = tasks;
            return this;
        }

        public void apply(){
            Lite.install(this);
        }
    }


}
